/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author milokokok
 */
@Entity
@Table(name = "item_basket")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ItemBasket.findAll", query = "SELECT i FROM ItemBasket i"),
    @NamedQuery(name = "ItemBasket.findById", query = "SELECT i FROM ItemBasket i WHERE i.id = :id"),
    @NamedQuery(name = "ItemBasket.findByCount", query = "SELECT i FROM ItemBasket i WHERE i.count = :count")})
public class ItemBasket implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "count")
    private int count;
    @JoinColumn(name = "id_product", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Products idProduct;
    @JoinColumn(name = "id_basket", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Baskets idBasket;

    public ItemBasket() {
    }

    public ItemBasket(Long id) {
        this.id = id;
    }

    public ItemBasket(Long id, int count) {
        this.id = id;
        this.count = count;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Products getIdProduct() {
        return idProduct;
    }

    public void setIdProduct(Products idProduct) {
        this.idProduct = idProduct;
    }

    public Baskets getIdBasket() {
        return idBasket;
    }

    public void setIdBasket(Baskets idBasket) {
        this.idBasket = idBasket;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemBasket)) {
            return false;
        }
        ItemBasket other = (ItemBasket) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.ItemBasket[ id=" + id + " ]";
    }
    
}
